package cn.fay.chapter07;

public class Test11 {
	public static void main(String[] args) {
		Detergent detergent=new Detergent();
		detergent.dilute();
		System.out.println(detergent);
		
	}
}
class Cleanser
{
	private String s="Cleanser";
	public void append(String a)
	{
		s+=a;
	}
	public void dilute()
	{
		append("dilute()");
	}
	public void apply() {
		append("apply()");
	}
	public void scrub() {
		append("scrub()");
	}
	public String toString() {
		return s;
	}
}
//用代理的方式，实现对Cleanser继承的效果
class Detergent
{
	private Cleanser cleanser=new Cleanser();
	public void append(String a) {
		 cleanser.append(a);
	}
	public void dilute() {
		cleanser.dilute();
	}
	public void apply() {
		cleanser.apply();
	}
	public void scrub() {
		cleanser.scrub();
	}
	public String toString() {
		return cleanser.toString();
	}
}